<!DOCTYPE html>
<html>
<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
    <meta charset="UTF-8">
    <title>固件添加</title>
    {% include 'template/baseCss.volt' %}
    <link href="/css/vendor/add-drone.less" rel="stylesheet/less" type="text/css">
    <script src="/js/less.min.js"></script>
</head>
<body>
<main>
    <form>
        <div class="title-bar">
            <label class="server-id">视频地面站版本信息编辑</label>
        </div>
        <div id="info-wrap">
            <table>
                <tr>
                    <th>版本号: </th>
                    <td>
                        <input type="text" id="version" value={{ data["version"] }}>
                    </td>
                </tr>
                <tr>
                    <th>内部版本号: </th>
                    <td>
                        <input type="text" id="code" value={{ data["code"] }}>

                    </td>
                </tr>
                <tr>
                    <th>强制升级: </th>
                    <td>
                        <input type="checkbox" id="force_update" {% if data["force_update"] == '1' %}checked{% endif %}>
                    </td>
                </tr>
                <tr>
                    <th>下载链接:</th>
                    <td>
                        <input type="text" id="url" value={{ data["url"] }}>
                    </td>
                </tr>
                <tr>
                    <th>版本说明:</th>
                    <td>
                        {#<div class="version-content" id="content"><?php echo $data["html"]?></div>#}
                    </td>
                </tr>
            </table>
            <div class="version-content">
                <div class="toolbar" id="editor-toolbar"></div>
                <div style="padding: 5px 0; color: #ccc"></div>
                <div class="text" id="editor-text" style="height: 400px;"><p>{{ data["description"] }}</p></div>
            </div>
        </div>
        <p id="save-btn" class="button" style="visibility: visible">保存</p>
        <p id="reset-btn" class="button" style="visibility: visible">重置</p>
    </form>
</main>
</body>

{% include 'template/baseJs.volt' %}
<script type="text/javascript" src="/third-part/wang-editor/wangEditor.min.js"></script>
<script src="/js/cos-js-sdk-v5.js"></script>
<script src="/js/vendor/upload-cos.js"></script>

<script>

    var editor = undefined;
    var id = getQueryString("id");

    $(function () {
        var E = window.wangEditor;
        editor = new E('#editor-toolbar', '#editor-text');
        editor.customConfig.zIndex = 100;
        editor.customConfig.menus = [
            'undo',  // 撤销
            'redo'  // 重复
        ];
        editor.create();
        CosUpload.cosInit("/file/getCosInfo");
    });

    $("#reset-btn").click(function (){
        location.reload();
    });

    $("#save-btn").click(function () {
        var data = {
            "action_key": REQUEST_ACTION_UPDATE,
            "id": id,
            "version": $("#version").val(),
            "code": $("#code").val(),
            "force_update": $("#force_update").is(":checked") ? 1 : 0,
            "url": $("#url").val(),
            "description": editor.txt.text()
        };
        loadingView.show();
        feimaPost("/version/detailVideoGSVersion", data, function (result) {
            if (result.status == 0) {
                loadingView.remove();
                window.location.href = "/version/listVideoGSVersion";
            } else {
                loadingView.remove();
                FAlert(result.message);
            }
        });
    });

</script>
</html>